{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
					<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">红娘id：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="matchmaker_id"   name="matchmaker_id" class="form-control" placeholder="请输入红娘id"  >
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">文字：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="content"   name="content" class="form-control" placeholder="请输入文字"  >
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">图片：</label>
						<div class="col-sm-6">
							<div class="images pic_list">
								<li id="images_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none images_process"></span>
						</div>
					</div>



					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<input name="status" value="1" type="radio" checked  title="通过">
							<input name="status" value="0" type="radio"    title="待审核">
						</div>
					</div>
					<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
	layui.use(['form'],function(){});
	laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
	uploader('images_upload', 'images', 'image', true, '{$info.pictures}', '{:getUploadServerUrl()}');
	setUploadButton('images_upload');

	var CodeInfoDlg = {
		CodeInfoData: {},
		validateFields: {
			status: {
				validators: {
					notEmpty: {
						message: '状态不能为空'
					},
				}
			},
		}
	}

	CodeInfoDlg.collectData = function () {
		this.set('content').set('matchmaker_id');
	};




	CodeInfoDlg.add = function () {
		this.clearData();
		this.collectData();
		if (!this.validate()) {
			return;
		}
		var images = [];
		$(".images li").each(function () {
			if ($(this).find('img').attr('src')) {
				images.push($(this).find('img').attr('src'));
			}
		});
		var status = $("input[name = 'status']:checked").val();
		var ajax = new $ax(Feng.ctxPath + "/ZhMatchmakerAddinfo/add", function (data) {
			if ('00' === data.status) {
				Feng.success(data.msg,1000);
				window.parent.CodeGoods.table.refresh();
				CodeInfoDlg.close();
			} else {
				Feng.error(data.msg + "！",1000);
			}
		})

		ajax.set('photos',images);
		ajax.set('status',status);
		ajax.set(this.CodeInfoData);
		ajax.start();
	};

</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
